{% extends "FOSUserBundle::layout.html.twig" %}
{% block head %}
{{parent()}}
{% if is_granted("IS_AUTHENTICATED_REMEMBERED") == false %}
	<meta http-equiv="refresh" content="1; url={{path('cadss_test_homepage')}}" />
	<script type="text/javascript">
            window.location.href = "{{ path('fos_user_security_login') }}"
    </script>
{% endif %}
{% endblock head %}

{% block fos_user_content %}
	{% if is_granted("IS_AUTHENTICATED_REMEMBERED") %}	
		<menu>
			<ul>
				<li><a>Keywords</a></li>
				<li>
					<form id="form_search" method="post" action="">
						<input type="text" class="searchfield" name="search" />
						<input type="submit" value="search" class="searchbutton" />
					</form>
				</li>
				<li><a onclick="var left = (screen.width/2)-(400/2); var top = (screen.height/2)-(400/2); window.open('{{ path('cadss_test_addkeyword') }}', '_blank', 'toolbar=no, scrollbars=no, resizable=no, top='+top+', left='+left+', width=400, height=400');">Add Keyword</a></li>
				<li><a href="{{ path('cadss_test_homepage') }}">Manage Documents</a></li>
				<li><a href="{{ path('fos_user_security_logout') }}">{{ 'layout.logout'|trans({}, 'FOSUserBundle') }}</a></li>
			</ul>
		</menu>
		<br />
		<br />
		<div id="files">
			<table>
				<tr>
					<th width="910">{{ keyword.keyword }}</th>
					<th width="100">
						<a onclick="var left = (screen.width/2)-(400/2); var top = (screen.height/2)-(400/2); window.open('{{ path('cadss_test_edit_keyword', {'id': keyword.id}) }}', '_blank', 'toolbar=no, scrollbars=no, resizable=no, top='+top+', left='+left+', width=400, height=400');"><img src="{{ asset('img/edit.png') }}" title="edit" alt="edit" width="15" height="15"/></a>
					</th>
				</tr>
				{% for file in keyword.documents %}
					<tr>
						<td>
							{{ file.dTitel }}
						</td>
						<td>
							<a href="{{ asset('uploads/documents/') }}{{ file.path }}">
								<img src="{{ asset('img/download.png') }}" title="download" alt="download" width="15" height="15"/>
							</a>
							{% if file.dUid == app.security.getToken().getUser().getId()  %}
								<a onclick="var left = (screen.width/2)-(400/2); var top = (screen.height/2)-(400/2); window.open('{{ path('cadss_test_edit_document', {'id': file.id}) }}', '_blank', 'toolbar=no, scrollbars=no, resizable=no, top='+top+', left='+left+', width=400, height=400');">
									<img src="{{ asset('img/edit.png') }}" title="edit" alt="edit" width="15" height="15"/>
								</a>
								<a href="{{ path('cadss_test_delete_document', {'id': file.id}) }}">
									<img src="{{ asset('img/delete.png') }}" title="delete" alt="delete" width="15" height="15"/>
								</a>
							{% endif %}
						</td>
					</tr>
				{% endfor %}
			</table>
		</div>		
    {% endif %}
{% endblock fos_user_content %}

